package com.yj.cmp.sdk.fusioncompute.identity;

import com.yj.cmp.sdk.fusioncompute.identity.dto.LoginDto;
import com.yj.cmp.sdk.fusioncompute.identity.vo.LoginVo;
import lombok.Data;
import org.springframework.stereotype.Component;
import retrofit2.Response;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Harvey_Yang
 * @date 2021/8/28 11:14
 */
@Data
@Component
public class FcIdentityApi {


    FcIdentityService fcIdentityService;

    public FcIdentityApi(FcIdentityService fcIdentityService) {
        this.fcIdentityService = fcIdentityService;
    }

    public Response<LoginVo> token(LoginDto loginDto) throws Exception {
        Map<String, String> headerMap = new HashMap<>(8);
        headerMap.put("X-Auth-UserType", "0");
        headerMap.put("Content-Type", "application/json; charset=UTF-8");
        headerMap.put("Accept-Language", "zh_CN");
        headerMap.put("X-ENCRIPT-ALGORITHM", "0");
        headerMap.put("X-Auth-User", loginDto.getUsername());
        headerMap.put("X-Auth-Key", loginDto.getPassword());
        return fcIdentityService.token(headerMap).execute();
    }


}
